package com.lecture.java8.excel;

import com.lecture.java8.excel.model.DemoData;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * @author luyn
 * @description
 * @Date 2020/9/24 15:15
 * @Version 1.0
 */
public class ExcelTestMain {

    public static void main(String[] args) {
        try {
            /*String fileName = "E:\\ZN\\1.xlsx";
            File file = new File(fileName);
            InputStream is = new FileInputStream(file);
            EasyExcel.read(is, new UserExcelListener()).sheet().doRead();
            UserInfo userInfo = new UserInfo();
            userInfo.setName("名称");
            ExcelUtil.getUserInfo(userInfo);
            System.out.println(userInfo.getName());
            int i = 1;
            ExcelUtil.getInt(i);
            System.out.println(i);
            String str = new String("字符串");
            ExcelUtil.getStr(str);
            System.out.println(str);*/
            String fileName = "D:\\study\\tmp\\excel\\123.xlsx";
            // 这里 需要指定写用哪个class去写，然后写到第一个sheet，名字为模板 然后文件流会自动关闭
            // 如果这里想使用03 则 传入excelType参数即可
            List<DemoData> list = new ArrayList<>();
            DemoData demoData = new DemoData();
            demoData.setId(1L);
            demoData.setString("a");
            demoData.setDate(new Date());
            demoData.setStr("se2343t");
            demoData.setDoubleData(132.7);

            DemoData demoData1 = new DemoData();
            demoData1.setId(1L);
            demoData1.setString("a");
            demoData1.setDate(new Date());
            demoData1.setStr("s34et");
            demoData1.setDoubleData(12.237);

            DemoData demoData2 = new DemoData();
            demoData2.setId(1L);
            demoData2.setString("a");
            demoData2.setDate(new Date());
            demoData2.setStr("set34");
            demoData2.setDoubleData(12223.7);

            list.add(demoData);
            list.add(demoData1);
            list.add(demoData2);


            /*List<DemoData> list1 = new ArrayList<>();
            DemoData demoData1 = new DemoData();
            //demoData1.setDate(new Date());
            demoData1.setDoubleData(888.333D);
            demoData1.setId(837377L);
            demoData1.setIgnore("dfsdf");
            demoData1.setString("sdfsdf");
            list1.add(demoData1);

            boolean equalList = ListUtils.isEqualList(list, list1);
            System.out.println(equalList);

            System.out.println(list.size());

            Iterator<DemoData> iterator = list.iterator();
            boolean b = iterator.hasNext();
            System.out.println(b);*/
            //EasyExcel.write(fileName, DemoData.class).sheet("模板").doWrite(list);
            //需要合并的列
            int[] mergeColumeIndex = {1};
            // 从那一列开始合并
            int mergeRowIndex = 1;
            /*EasyExcel.write(fileName, DemoData.class)
                    .sheet("SheetName")
                    //设置合并单元格策略
                    .registerWriteHandler(new ExcelFillCellMergeStrategy(mergeRowIndex, mergeColumeIndex))
                    .doWrite(list);*/
            /*ExcelWriter excelWriter = EasyExcel.write(fileName,DemoData.class).build();
            WriteSheet w1 = EasyExcel.writerSheet("模板1").head(DemoData.class).build();
            WriteSheet w2 = EasyExcel.writerSheet("模板2").head(DemoData.class).build();
            excelWriter.write(list,w1);
            excelWriter.write(list,w2);
            excelWriter.finish();*/
            LocalDateTime localDateTime = LocalDateTime.now();
            System.out.println(localDateTime.getYear()+"年"+localDateTime.getMonthValue() + "月" + localDateTime.getDayOfMonth() + " "
                    + localDateTime.getHour() + "时" + localDateTime.getMinute() + "分方案1");
            System.out.println(UUID.randomUUID().toString().replace("-","").length());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main7(String[] args) {
        /*DemoData dem3 = DemoData.builder().date(new Date()).doubleData(17833.33D).id(3L).ignore("dfjjf").build();
        DemoData dem1 = DemoData.builder().date(new Date()).doubleData(12323.34D).i d(1L).ignore("dfsdf").build();
        DemoData dem2 = DemoData.builder().date(new Date()).doubleData(23423423D).id(2L).ignore("fdsdg").build();

        List<DemoData> list = new ArrayList<>();
        list.add(dem3);
        list.add(dem1);
        list.add(dem2);

        Iterator<DemoData> iterator = list.iterator();
        while (iterator.hasNext()) {
            DemoData next = iterator.next();
            System.out.println(next.getId());
        }*/

        /*//-3的源码
        int binary = 0b10000000000000000000000000000011;
        //-3的反码
        int inverseCode = 0b11111111111111111111111111111100;
        //-3的补码
        int complementCode = 0b11111111111111111111111111111101;
        System.out.println(complementCode);

        //-3的左移<<2的补码
        int leftComplementCode = 0b11111111111111111111111111110100;
        //反码
        int leftInverseCode = 0b11111111111111111111111111110011;
        //原码
        int leftBinary = 0b10000000000000000000000000001100;

        System.out.println(0b11111111111111111111111111110100);
        System.out.println(-3<<2);

        int b = 0b111111  11111111111111111111111111;
        System.out.println(b);*/

        String str = "f";
        System.out.println("length of two Chinese character: " + str.getBytes().length );

    }
}
